/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mouseident;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.ArrayList;

/**
 *
 * @author matze
 */
public class MouseIdentCanvas extends Canvas {


    ArrayList<Node> parcour = new ArrayList<Node>();

    public void setParcour(ArrayList<Node> Parcour) {
        this.parcour = Parcour;
    }

    @Override
    public void paint(final Graphics g) {
        for (Node n : parcour) {
            if (!n.isVisited()) {
                Color color = n.getColor();
                g.setColor(color);
                g.fillOval(n.getX() - 10, n.getY() - 10, 20, 20);

                // when the color is  too dark, use white for the text
                if (color.getRed() + color.getGreen() + color.getBlue() < 380) {
                    g.setColor(Color.WHITE);
                } else {
                    g.setColor(Color.BLACK);
                }
                g.setFont(new Font("Arial", Font.BOLD, 10));
                g.drawString("" + parcour.indexOf(n), n.getX() - 3, n.getY() + 5);
            }
        }
    }




}
